home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 11
/
Cream of the Crop 11-1.iso
/
utility
/
horst_2.zip
/
READ.ME2
< prev
next >
Wrap
Text File
|
1995-12-18
|
13KB
|
247 lines
-*- HORST_2.LZH -*-
14 May 1995
---------------------------------------------------------------------------
This this file contains expanded discussions of some of the programs
contained in the HORST_2 archive, plus background material. It is
intended for relative beginners to batch programming and won't be needed
by BATPOWER old hands! Please direct criticisms, suggestions and
comments to Robert Bull at Fidonet 2:254/33.4, as it may be extended in
further versions. The material was checked by Horst before inclusion.
---------------------------------------------------------------------------
Files added to the archive by Robert Bull;
READ.ME2 (this file)
ECHECK.BAT very simple batch file to demonstrate errorlevels
SCRPCHK.BAT uses CRC32 and NSET to check files encoded with CSCRIPT
H4.BAT uses QECHO to send control codes to a LaserJet 4 Plus
(needs PMENUE as well)
SHUTDOWN.BAT uses DREADY to make sure the disk drives are empty before
turning off the computer
---------------------------------------------------------------------------
A note for 4DOS / NDOS users
4DOS and NDOS, a version of 4DOS sold with Norton Utilities, are very much
enhanced replacements for COMMAND.COM, DOS's own command processor. Users
of those excellent products will be aware that there is some overlap
between 4DOS built-in commands and Horst's utilities, but they are
completely compatible, as far as is known. You may well prefer Horst's
programs for some jobs. In particular, computer support staff may not be
given the chance to install 4DOS on all of a company's PCs; it is
therefore nice to know that other utilities are available to do some of
the same jobs, and that those jobs be set up on a 4DOS machine with
complete confidence that they will run properly on a plain one.
---------------------------------------------------------------------------
Descriptions
ANSTRIP
Many batch files contain ANSI control codes. These are usually used to
give colourful screens, but can also be used to redefine the keyboard
or to move the cursor. ANSTRIP strips ANSI codes out of text files for
a clean display on non-ANSI monitors, and helps in converting batch
files to non-ANSI use. ANSTRIP has a feature to remove keyboard
redefinitions only, but this NOT a secure way of avoiding ANSI bombs,
i.e., malicious redefinitions of the keyboard so that innocent actions
like DIR cause destructive actions like DEL *.*.
---------------------------------------------------------------------------
CSCRIPT
CRC32
example: SCRPCHK.BAT, which feeds a file to DEBUG for decoding, and
tells you whether the CRC's matched. Needs NSET also.
SCRPCHK.BAT has been commented.
Most bulletin-board system (BBS) users know about downloading files. Some
even know about uploading files. Few know that files can be transmitted
through normal e-mail as messages, as long as they are encoded. If you
look at many files types, such as .COM files, .EXE files and archives
(.ZIP, .LZH, etc.) with a file lister such as Buerg's LIST.COM, you will
see they are full of funny-looking high-ASCII characters, owing to the way
the files are stored on disk. These characters can cause e-mail systems
to crash, so encoding systems have been invented to replace them with
ordinary alphanumeric characters (plus a few others). They are then
reassembled at the other end with a suitable decoder; conveniently, this
is DEBUG, which comes free with most versions of DOS. Many small but
useful files have been shared around the Fidonet BATPOWER echo this way.
CRC checking is a way of checking that a file has not been corrupted.
A calculation of its contents is made and presented as a number.
CSCRIPT adds this number to the tail of each file it encodes. You run
CRC32 over the file you have just decoded with DEBUG and check that the
CRC values match.
While often very useful and much appreciated, transmitting scripts
takes up a lot of bandwidth in an echo and costs everyone (especially
sysops) money in telephone costs. Therefore, please check the echo
rules to make sure that posting files as scripts is actually allowed,
please restrict such postings to files specifically intended to help
somebody out of a hole (i.e. no unsolicited postings to "All"), please
don't post files already widely available, and please keep postings to
files of reasonable size.
The earlier version of CSCRIPT, 1.x, was primarily intended for small
files. It had a size limit of 12K but should not be used for files
exceeding a few hundred bytes. If your file is bigger than that, Chad
Wagner's XXBUG (3.0 at the time of writing) is most popular, but many
prefer the "official" method of UU or XX encoding, as exemplified by
Richard E. Marks' UUDECODE (UUEXE525).
Horst Schaeffer's new CSCRIPT ver. 2.2 now includes options for XX- and
UUencoding (with or without DEBUG header), and still has a reasonable
program size (about 1.400 bytes). It is small enough to be encoded as a
script for transmission through the e-mail system without imposing an
unreasonable burden on the bandwidth, and takes up little hard disk space.
Multi-page scripts, however, are not supported.
---------------------------------------------------------------------------
ESPACE
example: ECHECK.BAT (a very simple example to demonstrate use of
errorlevels)
Ever had one of those "out of environment space" messages? Here's a
way of avoiding them. ESPACE reports how much environment space is
left, and, optionally, whether there is as much left as you specify.
This means that you can take action before starting a batch file that
uses a lot of environment space. If there is less than you know
the .BAT needs, try loading a second copy of the command processor,
i.e., issue the command
COMMAND /E:nnnn
which gives you a secondary DOS shell with another nnnn bytes of
environment space. nnnn = 2048 seems quite a good figure.
---------------------------------------------------------------------------
NOEMPTY
NOEMPTY is a filter for removing blank lines from files. You wouldn't
often do this with normal document files, but it is useful when dealing
with sorted lists, perhaps those produced by other filters which in
deleting lines have left them blank. I used an AWK one-liner before I
had NOEMPTY, but NOEMPTY is faster (four times faster!) and more
reliable.
Horst also made LISTMOD ignore blank lines, so you can in fact use
LISTMOD as a no-empty filter as well. Two things to note; (a) LISTMOD
has a 60K input file size limit, and (b) LISTMOD will left-justify all
output when used like this, which you may or may not want, depending on
circumstances.
---------------------------------------------------------------------------
KPUSH
Some batch file operations can't be fully automated because at some point
or other a certain key has to be pressed. Often there is good reason for
your full attention, but on occasion you have a routine operation to
perform and find it a nuisance. The IBM PC-compatible has a keyboard
buffer, that is, a small section of memory that can hold up to 15
keystrokes at a time. The main purpose of this is to catch extra
keystrokes when you type faster than a program can accept them, so that
they are not lost, but released as fast as the program can react. KPUSH
is a program that allows you to stuff keypresses into that buffer, usually
from a batch file, allowing you to perform many actions hands-off.
KPUSH has another function. It can tell you the correct codes for keys
you want to enter into a KPUSH script. If you issue the command KPUSH at
the command line, it announces its presence and puts a flashing cursor on
the screen. If you then press a key, KPUSH returns that key's "scan
code," as well as its ASCII code, where it has one. The scan code is the
value the key returns to DOS when it is pressed. It is important to know
that this is not the same as the ASCII value marked on the key top. Some
keys, like cursor and function keys, do not have ASCII values, but they do
have scan codes. Conversely, the grey "+" key on the numeric keypad has a
different scan code from the white "+" key on the main keyboard, even
though they have the same ASCII values. Any key can be KPUSHed into the
buffer by using its scan code.
Having only 15 keypresses can be limiting. Horst has overcome this by
making KPUSH extend the buffer to 127 characters. That should be enough
for most people but if you do need even more, try keyboard buffer
extenders such as BIGBUF.SYS.
Having keypresses already pending in the buffer before KPUSH was run could
cause problems. KPUSH has a flush feature, which clears the buffer of any
keypresses already in it before introducing its own.
Occasionally you will find that KPUSH and similar programs will throw key
presses at a program faster than the program can react. This happens
with, for example, some of PC-Write's Alt-{char} font characters, though
other stuffed keys behave perfectly. KPUSH can not overcome this; it
would need to be a TSR, a RAM-resident program, an approach which uses
memory and can cause conflicts with other programs. Another problem is
when some programs clear the buffer themselves on entry, thereby flushing
and losing any keypresses that KPUSH has placed there.
---------------------------------------------------------------------------
QECHO
example: H4.BAT
Please note - you need PMENUE as well for this. PMENUE was
included in the previous archive HORST_1.LZH, but will shortly be
moved into a separate archive of its own as PMENUE15.LZH, so is
not included here.
If you have tried to use DOS's own ECHO command, you will realise that it
is pretty limited. It always ends input with a carriage return whether
you want one or not, which can, for example, add unnecessary blank lines
if you use it to control a printer. Equally, have you ever tried to echo
control codes to a printer directly from the command line? If you tried
to send a code sequence that contained the ASCII 027 ESCape character, you
probably had the whole line evaporate in front your eyes! QECHO overcomes
these limitations.
For example, I wanted to send control codes to a LaserJet 4 Plus printer.
I needed to be able to re-set it after a very expensive commercial program
that didn't always get the page length right, to send form feeds (page
ejects) after screen prints and the like (the printer is so far from the
PC that the control panel is hard to reach!), and also to be able to set
certain fonts for printing plain ASCII files from DOS. A program called
SETUP2, originally from PC Magazine, was posted in the BATPOWER echo for
just this sort of job. It turned out to be a rather badly-behaved TSR.
When QECHO became available as well as Horst's earlier PMENUE batch
menuing program, I hastily converted Horst's own PMENUE demo into H4.BAT
so as to work with QECHO to send Hewlett-Packard PCL5 control code
sequences, containing the ESCape character amongst others. There's no
guarantee of whether _all_ the control codes in H4.BAT work as advertised;
but the re-set and page eject do! (I feel a modification of this .BAT
coming on now Horst has given us PCHECK...)
---------------------------------------------------------------------------
DREADY
example: SHUTDOWN.BAT
I got to work one day only to fume with frustration at finding I'd left a
disk I wanted at home. I knew exactly where it was - in the A: drive of
my home machine. Likewise, I've come into work in the morning, turned the
machine on, only to get an error message that the disk was not bootable.
I'd left the last of the back-up disks in the floppy drive overnight,
thereby making a mockery of trying to keep data safe by keeping a separate
copy away from the computer. Clearly I needed a way of reminding myself
to check that the drive was empty. I habitually run a SHUTDOWN.BAT before
turning the computer off, and DREADY gave an excellent way of adding into
it a check on the whether there was a floppy in the drive. The example
SHUTDOWN.BAT shows how it is used to check both A: and B: drives of the
machine I use at work.
---------------------------------------------------------------------------